<template>
  <fade>
    <div class="gallary" v-show="isShowGallary" v-on:click="handleCloseGallary">
      <div class="img-wrapper">
        <swiper :options="swiperOption" v-if="gallaryList.length">
          <swiper-slide v-for="item in gallaryList" :key="item.id">
            <img class="swiper-img" :src="item.imgUrl" />
          </swiper-slide>
        </swiper>
      </div>

      <div class="swiper-pagination" slot="pagination"></div>
    </div>
  </fade>
</template>

<script>
import Fade from "common/fade/Fade";

export default {
  name: "Gallary",
  props: {
    gallaryList: Array,
    isShowGallary: Boolean
  },
  components: {
    fade: Fade
  },
  data() {
    return {
      swiperOption: {
        pagination: ".swiper-pagination", //分页器圆点
        paginationType: "fraction",
        loop: true, //设置循环轮播，无缝
        autoplay: 3000,
        observer: true, //检查样式变化 并初始化
        observeParents: true //检查父级元素变化 并初始化
      }
    };
  },
  methods: {
    handleCloseGallary: function() {
      this.$emit("closeGallary");
    }
  }
};
</script>

<style lang="stylus" scoped>
.gallary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: fixed;
  z-index: 99;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000;
  color: #fff;
}

.gallary >>> .swiper-container {
  width: 100%;
  height: 100%;
}

.gallary >>> .swiper-slider {
  flex-direction: column;
  justify-content: center;
}

.gallary >>> .swiper-pagination {
  color: #fff;
}
</style>